package com.tedu.lingma.agent.utils;

import com.tedu.lingma.agent.domain.Appointment;
import com.tedu.lingma.agent.domain.Departments;
import com.tedu.lingma.agent.service.AppointmentService;
import com.tedu.lingma.agent.service.DepartmentsService;
import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.UUID;

@Component
public class AssistantTools {
    private final AppointmentService appointmentService;

    private final DepartmentsService departmentsService;


    public AssistantTools(AppointmentService appointmentService, DepartmentsService departmentsService) {
        this.appointmentService = appointmentService;
        this.departmentsService = departmentsService;
    }

    /**
     * 预约挂号
     */
    @Tool(name = "预约挂号",value = "预约挂号")
    public String appointment(@P("挂号数据封装对象")Appointment appointment) {
        if(appointment == null){
            return "预约失败";
        }
        appointment.setAppointmentId(UUID.randomUUID().toString());
        if (appointmentService.save(appointment)){
            return "预约成功";
        }
        return "预约失败";
    }

    @Tool(name = "查询科室",value = "查询科室")
    public String searchDepartments() {
        List<Departments> list = departmentsService.list();
        return "科室介绍："+list;
    }


    @Tool(name = "查询医生",value = "查询医生")
    public String searchDoctors(@P("科室名称")String deptName) {
        System.out.println(deptName+"=====================");
        return "科室介绍："+deptName;
    }


}
